<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\ProfitSharingList;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController;

class ProfitSharingListController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new ProfitSharingList(), function (Grid $grid) {
            $grid->id->sortable();
            $grid->channel;
            $grid->sub_mchid;
            $grid->sub_appid;
            $grid->trans_id;
            $grid->profit_sharing_order_id;
            $grid->accounts;
//            $grid->status;
            $grid->ps_time;
            //$grid->ps_msg;
//            $grid->finish_time;
            //$grid->finish_msg;
//            $grid->return_time;
            //$grid->return_msg;
            $grid->created_at;
            //$grid->updated_at->sortable();

            // 禁用按钮
            $grid->disableCreateButton();
            $grid->disableDeleteButton();
            $grid->disableEditButton();

            // 筛选
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
                $filter->like('channel');
                $filter->like('sub_mchid');
                $filter->like('sub_appid');
                $filter->like('trans_id');
                $filter->like('profit_sharing_order_id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new ProfitSharingList(), function (Show $show) {
            $show->id;
            $show->channel;
            $show->sub_mchid;
            $show->sub_appid;
            $show->trans_id;
            $show->profit_sharing_order_id;
            $show->accounts;
            $show->ps_time;
            $show->ps_msg;
            $show->finish_time;
            $show->finish_msg;
            $show->return_time;
            $show->return_msg;
            $show->created_at;
            $show->updated_at;

            $show->disableDeleteButton();
            $show->disableEditButton();
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new ProfitSharingList(), function (Form $form) {
            $form->display('id');
            $form->text('channel');
            $form->text('sub_mchid');
            $form->text('sub_appid');
            $form->text('trans_id');
            $form->text('profit_sharing_order_id');
            $form->text('accounts');
            $form->text('ps_time');
            $form->text('ps_msg');
            $form->text('finish_time');
            $form->text('finish_msg');
            $form->text('return_time');
            $form->text('return_msg');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
